package edu.ycu.aladdin.web.controller;

import edu.ycu.aladdin.web.api.TestAPI;
import edu.ycu.aladdin.web.api.crawler.TestCookieAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 1.0
 */
@Slf4j
@Controller
@RequestMapping("/test")
public class TestController extends AbsController implements TestAPI, TestCookieAPI {


    @Override
    public String test() {
        return "hello controller implements api";
    }

    @Override
    public void setCookieTest(HttpServletRequest request, HttpServletResponse response){
        String contextPath = request.getContextPath();
        String requestURI = request.getRequestURI();
        String servletPath = request.getServletPath();
        setCookie("testKey","testVvalue",response);
        log.info("contextPath:{},requestURI:{},servletPath:{}",contextPath,requestURI,servletPath);
    }
}
